const express = require('express');
const router = express.Router();
const { adminAuth } = require('../middleware/auth');
const adminController = require('../controllers/adminController');

// 所有管理员路由都需要管理员权限
router.use(adminAuth);

// 用户管理
router.get('/users', adminController.getAllUsers);
router.get('/users/:id', adminController.getUserDetail);
router.put('/users/:id', adminController.updateUser);
router.delete('/users/:id', adminController.deleteUser);
router.put('/users/:id/status', adminController.updateUserStatus);

// 学习数据统计
router.get('/statistics/overview', adminController.getOverviewStats);
router.get('/statistics/users', adminController.getUsersStats);
router.get('/statistics/progress', adminController.getProgressStats);
router.get('/statistics/checkin', adminController.getCheckinStats);

// 资源管理
router.get('/resources', adminController.getAllResources);
router.post('/resources', adminController.createResource);
router.put('/resources/:id', adminController.updateResource);
router.delete('/resources/:id', adminController.deleteResource);

// 数据导出
router.get('/export/users', adminController.exportUsers);
router.get('/export/progress', adminController.exportProgress);

module.exports = router; 